<?php


namespace App\Admin\Controllers\Export;

use App\Exports\GoodsExport;
use Encore\Admin\Layout\Content;
use Illuminate\Http\Request;
use Maatwebsite\Excel\Facades\Excel;

/**
 * Created By FreeAbrams
 * Date: 2020/11/26
 */
class GoodsExportController extends Controller
{
	public function index(Content $content)
	{
		return $content
			->header('菜品分析')
			->row(view('admin.export.year-select', [
			'route' => route('goodsExport'),
			'routeIndex' => route('goodsExport.index')
		]));
	}
	
	public function export(Request $request)
	{
		$timeBetween = $this->requestReturnTimeBetween($request);
		if(empty($timeBetween)){
			return false;
		}
		
		return Excel::download(new GoodsExport($timeBetween), '菜品.xls');
	}
}